//
//  GDBaseTabBarController.m
//  ServiceDemo
//
//  Created by apple on 16/2/16.
//  Copyright (c) 2016年 HuaZhengInfo. All rights reserved.
//

#import "GDBaseTabBarController.h"

@interface GDBaseTabBarController ()

@end

@implementation GDBaseTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
}

- (void)addViewControllerWithName:(NSString *)controller title:(NSString *)title image:(NSString *)imageName selectedImage:(NSString *)selectedImageName{

    // 1.获取控制器
    Class viewC = NSClassFromString(controller);
    UIViewController *vc = [[viewC alloc] init];
    
    // 2.设置属性
    vc.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:imageName];
    vc.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
    
    // 3.包装
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    
    // 4.添加
    // self.viewControllers 获取TabBarViewController中包含的控制器
    NSMutableArray *arrayM = [NSMutableArray arrayWithArray:self.viewControllers];
    [arrayM addObject:nav];
    self.viewControllers = arrayM;
    
}

@end
